
<template>
    <el-aside width="200px">
        <el-scrollbar>
            <el-menu :default-openeds="['1', '3']">
                <template v-for="item in menu.menus">
                    <template v-if="item.children">
                        <el-sub-menu :index="item.name">
                            <template #title>
                                <el-icon>
                                    <message />
                                </el-icon>{{ item.name }}
                            </template>
                            <el-menu-item-group v-if="item.children" v-for="children in item.children"
                                :index="children.name">
                                <el-menu-item :index="children.name" @click="onClick(children)">{{ children.name
                                }}</el-menu-item>
                                <!-- <template #title>{{ children.meta.permission }}</template> -->
                                <!-- <el-menu-item index="2-4-1">Option 4-1</el-menu-item> -->
                            </el-menu-item-group>
                        </el-sub-menu>
                    </template>
                    <el-menu-item v-else @click="onClick(item)">
                        <el-icon><icon-menu /></el-icon>
                        <span>{{ item.name }}</span>
                    </el-menu-item>
                </template>
            </el-menu>
        </el-scrollbar>
    </el-aside>
</template>

<script lang="ts" setup>
import router from '@/router'
import { ref } from 'vue'
import { Menu as IconMenu, Message, Setting } from '@element-plus/icons-vue'
import { useMenuStore } from '@/store/modules/menu'

defineOptions({
    name: 'ShAside',
})
const menu = useMenuStore()
function onClick(item: any) {
    router.push({ name: item.name })
}
</script>

<style scoped></style>